#!/bin/bash

# 使用方法： source scripts/warehouse_env_config.sh


if [ ! -f "$PWD/CMakeLists.txt" ]; then
	echo "错误: 请在项目的根目录执行此脚本" >&2
	return 1
fi

# 确保环境变量只配置一次
if [ ! $WAREHOUSE_CONFIG ]; then
	echo "开始配置warehouse环境变量"
	export WAREHOUSE_CONFIG=1
else
	export WAREHOUSE_CONFIG=0
	echo "已配置过"
	return 0
fi


export WAREHOUSE_DIR="$PWD"
export WAREHOUSE_DATA_DIR="$PWD/data"
export WAREHOUSE_INCLUDE_DIR="$PWD/include"
export WAREHOUSE_LIB_DIR="$PWD/lib"
export LD_LIBRARY_LIB=$WAREHOUSE_LIB_DIR:$LD_LIBRARY_LIB

# 创建必要的本地文件，用以程序本地存储
touch $WAREHOUSE_DATA_DIR/userlist.txt
touch $WAREHOUSE_DATA_DIR/warehouse.dat
touch $WAREHOUSE_DATA_DIR/log.txt
